﻿<UserControl x:Class="EpubManga.Options"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:manga="clr-namespace:EpubManga">

    <UserControl.Resources>
        <ResourceDictionary Source="./Styles/Style.xaml"/>
    </UserControl.Resources>
    
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="27"/>
            <RowDefinition Height="27"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="85"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="85"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="85"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="85"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>


        <TextBlock Grid.Row="0" Grid.Column="0" Text="Grayscale"/>
        <CheckBox Grid.Row="0" Grid.Column="1"
            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolInverterConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            IsChecked="{Binding Data.Grayscale, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>

        <TextBlock Grid.Row="0" Grid.Column="2" Text="Trimming"/>
        <CheckBox Grid.Row="0" Grid.Column="3"
            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolInverterConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            IsChecked="{Binding Data.Trimming, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>

        <TextBlock Grid.Row="0" Grid.Column="4" Text="Trim. Level"
            Visibility="{Binding Data.Trimming, Converter={StaticResource BoolToVisibilityConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
        <ComboBox Grid.Row="0" Grid.Column="5" IsReadOnly="True"
            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolInverterConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            SelectedItem="{Binding Data.TrimmingLevel, Converter={StaticResource TrimmingLevelToStringConv}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
            ItemsSource="{Binding Data.AvailableTrimmingLevels, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            Visibility="{Binding Data.Trimming, Converter={StaticResource BoolToVisibilityConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}">
            <ComboBox.Resources>
                <Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="{x:Type TextBlock}">
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ComboBox.Resources>
        </ComboBox>

        <TextBlock Grid.Row="0" Grid.Column="6" Text="Trim. Method"
            Visibility="{Binding Data.Trimming, Converter={StaticResource BoolToVisibilityConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
        <ComboBox Grid.Row="0" Grid.Column="7" IsReadOnly="True"
            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolInverterConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            SelectedItem="{Binding Data.TrimmingMethod, Converter={StaticResource TrimmingMethodToStringConv}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
            ItemsSource="{Binding Data.AvailableTrimmingMethods, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            Visibility="{Binding Data.Trimming, Converter={StaticResource BoolToVisibilityConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}">
            <ComboBox.Resources>
                <Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="{x:Type TextBlock}">
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ComboBox.Resources>
        </ComboBox>


        <TextBlock Grid.Row="1" Grid.Column="0" Text="Height"/>
        <TextBox Grid.Row="1" Grid.Column="1"
            manga:TextBoxExtension.Regexp="Integer"
            IsReadOnly="{Binding IsBusy, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            Text="{Binding Data.Height, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>

        <TextBlock Grid.Row="1" Grid.Column="2" Text="Left Margin"/>
        <TextBox Grid.Row="1" Grid.Column="3"
            IsReadOnly="{Binding IsBusy, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            Text="{Binding Data.LeftMargin, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>


        <TextBlock Grid.Row="1" Grid.Column="4" Text="Double Page"/>
        <ComboBox Grid.Row="1" Grid.Column="5" IsReadOnly="True"
            IsEnabled="{Binding IsBusy, Converter={StaticResource BoolInverterConv}, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            SelectedItem="{Binding Data.DoublePage, Converter={StaticResource DoublePageToStringConv}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
            ItemsSource="{Binding Data.AvailableDoublePages, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}">
            <ComboBox.Resources>
                <Style BasedOn="{StaticResource {x:Type TextBlock}}" TargetType="{x:Type TextBlock}">
                    <Setter Property="Margin" Value="0"/>
                    <Setter Property="Padding" Value="0"/>
                </Style>
            </ComboBox.Resources>
        </ComboBox>
        
        <TextBlock Grid.Row="1" Grid.Column="6" Text="Offset"
            Visibility="{Binding Data.IsOffsetVisible, Converter={StaticResource BoolToVisibilityConv}, ConverterParameter=true, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
        <TextBox Grid.Row="1" Grid.Column="7"
            manga:TextBoxExtension.Regexp="NegativeInteger"
            IsReadOnly="{Binding IsBusy, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"
            Text="{Binding Data.Offset, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
            Visibility="{Binding Data.IsOffsetVisible, Converter={StaticResource BoolToVisibilityConv}, ConverterParameter=true, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/>
        
    </Grid>
</UserControl>
